using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LineManager : MonoBehaviour
{

    public GameObject player;
    public Camera cam;
    Vector2 lastpos;
    Vector2 curpos;
    public GraphLine Line;
    [SerializeField] private LineMind linePrefabs;
    private LineMind currentLine;
    public bool isDrawing;
    public const float resolution = 0.1f;
    public float speed;
    public GameObject firstPoint;
    public GrappleHook pplayer;
    private void Start()
    {
        //GraphLine line = GameObject.Find("StartPoint").GetComponent<GraphLine>();
        //Line=firstPoint.GetComponent<GraphLine>();
        //isDrawing = line.isDrawing;
    }
    private void Update()
    {
        Line = firstPoint.GetComponent<GraphLine>();
        pplayer=player.GetComponent<GrappleHook>();
        curpos = player.transform.position;
        speed = (Vector3.Magnitude(curpos - lastpos) / Time.deltaTime);
        lastpos = curpos;
        if (Input.GetMouseButtonDown(0))
        {
            currentLine = Instantiate(linePrefabs, player.transform.position, Quaternion.identity);
        }
        if (Line.isDrawing&&pplayer.isDrawing)
        {
            currentLine.SetPosition(player.transform.position);

        }



    }
    
}
